package cn.wolfcode.trip.base.service.impl;


import cn.wolfcode.trip.base.domain.Ticket;
import cn.wolfcode.trip.base.mapper.TicketMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.ITicketService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class TicketServiceImpl implements ITicketService {
    @Autowired
    private TicketMapper ticketMapper;

    @Override
    public void saveTicketPrice(Ticket ticket) {
        ticketMapper.updateTicketPrice(ticket);
    }

    @Override
    public Ticket getTicket(Long id) {
        return ticketMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<Ticket> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
       List<Ticket> list=ticketMapper.queryForList(qo);
        return new PageInfo<Ticket>(list);
    }

    @Override
    public void Update(Ticket ticket) {
        ticketMapper.updateByPrimaryKey(ticket);
    }

    @Override
    public void changeState(Integer type, Long id) {
        ticketMapper.changeState(type,id);
    }
}
